<?php

	class UserModel extends Dbini{
		private $table = 'user';
		
		public function __construct(){
			parent::__destruct();
		}
		
		/**
		 * 获取用户数据
		 * @param UserEntity $userEntityObj
		 */
		public function listUsers(UserEntity $userEntityObj){
			if(is_object($userEntityObj) && !empty($userEntityObj)){
				$sql = "SELECT * FROM {$this->table} WHERE 1=1 ";
				$userId = trim($userEntityObj -> getUserId());
				if(!empty($userId)){
					$sql = " AND userId = {$userId} ";
				}
				$userName = trim($userEntityObj -> getUserName());
				if(!empty($userName)){
					$sql = " AND userName = {$userName} ";	
				}
				$stmtObj = $this->db->prepare($sql);
				$stmtObj -> execute();
				$rs = $stmtObj -> fetchAll(PDO::FETCH_ASSOC);
				return $rs;
			}
			return false;
		}
	}